package com.echo.code.thread.mode.active;

import com.echo.code.thread.queue.BlockingQueue;

/**
 * ActiveDaemonThread Created by baiyap on 2018/10/6.
 */
public class ActiveDaemonThread extends Thread {

  private BlockingQueue<ActiveMessage> queue;

  public ActiveDaemonThread(BlockingQueue<ActiveMessage> queue) {
    this.queue = queue;
    setDaemon(true);
  }

  @Override
  public void run() {
    for (; ; ) {
      ActiveMessage activeMessage = queue.take();
      activeMessage.execute();
    }
  }
}
